# -*- coding:utf-8 -*-

from odoo import models

import logging
_logger = logging.getLogger(__name__)

class MemberDetail(models.Model):

    _inherit = 'membership.membership_line'

    def get_member(self, member_no='None'):

        # James add debug:
        _logger.info("\njames Debug,member_no=%s" %member_no)

        limit_clause = ' LIMIT 1' 
        self.env.cr.execute("""
            SELECT DISTINCT p.id
            FROM res_partner p INNER JOIN membership_membership_line m
            ON  p.id = m.partner
            WHERE member_no = '%s' """ + limit_clause, [member_no])
        return [partner_id[0] for partner_id in self.env.cr.fetchall()]